#ifndef _CHIP_H_
#define _CHIP_H_
#include "../../head_file.h"

//pinmux information
typedef struct 
{
    UINT32 pin_mux_sel;        /* value defined in chip_*.h*/ 
    UINT32 value;              /* register value */ 
}PinMuxInfo;

//gpio config
typedef struct pan_gpio_info GpioInfo;
//#define GpioInfo struct pan_gpio_info

typedef struct 
{
    BOOL mem_gpio_enabled;
    BOOL ali_ethmac_enabled; // NET_ALIETHMAC    
    BOOL ci_power_ctl_enabled; //1 enabled, 0 disabled  //set to 0 #if (SYS_MAIN_BOARD == BOARD_DB_M3603_01V01 || SYS_MAIN_BOARD == BOARD_DB_M3603_02V01)  && defined(CEC_SUPPORT)
    BOOL ci_vccen_active_high; 
    BOOL dual_enabled;       //not used now    
}ChipInitParam;

struct _Chip;
typedef struct _Chip Chip;

typedef void (*ChipPinMuxSet)(Chip* thiz, PinMuxInfo* pin_mux_info);
typedef void (*ChipPinMuxSetExt)(Chip* thiz, PinMuxInfo pin_mux_info[], UINT8 count);
typedef void (*ChipGpioSet)(Chip* thiz, GpioInfo* gpio_info, UINT8 value);
typedef UINT32 (*ChipGpioGet)(Chip* thiz, GpioInfo* gpio_info);
typedef void (*ChipGpioPinInit)(Chip* thiz, GpioInfo* gpio_info, BOOL enabled);
typedef void (*ChipGpioDirSet)(Chip* thiz, GpioInfo* gpio_info);
typedef void (*ChipGpioPinInitExt)(Chip* thiz, GpioInfo gpio_info[], UINT8 count);
typedef void (*ChipGpioDirSetExt)(Chip* thiz, GpioInfo gpio_info[], UINT8 count);
typedef void (*ChipInit)(Chip* thiz, ChipInitParam* param);
typedef void (*ChipDestory)(Chip* thiz);
typedef void (*ChipTsiPinCfg)(Chip* thiz, UINT8 tsi_id, BOOL clear);
typedef void (*ChipCiPower)(Chip* thiz, BOOL power_on);


struct _Chip
{
    ChipPinMuxSet       pin_mux_set;
    ChipPinMuxSetExt    pin_mux_set_ext;
    ChipGpioSet         gpio_set;
    ChipGpioGet         gpio_get;
    ChipGpioPinInit     gpio_pin_init;
    ChipGpioPinInitExt  gpio_pin_init_ext;
    ChipGpioDirSet      gpio_dir_set;
    ChipGpioDirSetExt   gpio_dir_set_ext;
    ChipTsiPinCfg       tsi_pin_cfg;
    ChipCiPower         ci_power;
    ChipInit            init;
    ChipDestory         destory;
    INT8 priv[];
};

void chip_pin_mux_set(PinMuxInfo* pin_mux_info);
void chip_pin_mux_set_ext(PinMuxInfo pin_mux_info[], UINT8 count);
void chip_gpio_pin_init(GpioInfo* gpio_info, BOOL enabled);
void chip_gpio_pin_init_ext(GpioInfo gpio_info[], UINT8 count);
void chip_gpio_set(GpioInfo* gpio_info, UINT8 value);
UINT32 chip_gpio_get(GpioInfo* gpio_info);
void chip_gpio_dir_set(GpioInfo* gpio_info);
void chip_gpio_dir_set_ext(GpioInfo gpio_info[], UINT8 count);
void chip_init(ChipInitParam* param);
void chip_tsi_pin_cfg(UINT8 tsi_id, BOOL clear);
void chip_ci_power(BOOL power_on);

void  global_chip_set(Chip* chip);
Chip* global_chip(void);
Chip* chip_create(void);

#define G_CHIP  global_chip()

#endif

